#pragma once
#include <stdint.h>

namespace HW
{
namespace Memory
{
namespace Pool
{
	typedef uint32_t RosterElement;
	typedef RosterElement* Roster;

	struct PoolContainer
	{
		uint8_t* pool;
		Roster roster;
		RosterElement rosterFreePartition;
		size_t elementSize;
		uint32_t elementCount;
		bool isUsed;
		uint8_t padding[3];
	};

	void InitPool ( uint8_t* poolRoot , Roster rosterRoot , PoolContainer* poolContainer , uint32_t count );
	bool CreatePool ( uint8_t* poolRoot , Roster rosterRoot , PoolContainer* poolContainer , uint32_t count );
	RosterElement AllocateFromPool ( PoolContainer& poolContainer );
	bool DeallocateFromPool ( PoolContainer& poolContainer , const RosterElement id );
	bool IsAllocated ( const PoolContainer& poolContainer , const RosterElement id );
	RosterElement FindElementInRoster ( const PoolContainer& poolContainer , const RosterElement id );
}
}
}